package com.neuedu.mvc.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 项目：      spring-framework
 * 类名:       ValidateLoginInterceptor
 * 创建时间：  2024/3/21 08：58
 * 描述 :
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
public class ValidateLoginInterceptor implements HandlerInterceptor {


    //在handler方法之前执行，返回true就继续执行 handler方法，返回false 不执行 handler方法
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("1.1 ValidateLoginInterceptor.preHandle");
        return true;
    }

    //在handler方法执行之后， handler报错不执行
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("1.2 ValidateLoginInterceptor.postHandle");
    }


    //在handler方法执行之后， 不报错也执行
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("1.3 ValidateLoginInterceptor.afterCompletion");
    }
}
